require_relative "helper"
require "hops"

describe Hops do

  it "must adjust IBUs based on boil time" do
    (Hops.time_adjustment 60).must_equal 0.91
  end

  it "must adjust IBUs based on extract" do
    (Hops.extract_adjustment 1.055).must_equal 1.01
  end

  it "must calculate hop utilization" do
    (Hops.utilization 10, 1.065).must_equal 0.07
  end

  it "must calculate IBUs from hop addition" do
    Hops.ibus({
      extract: 1.05,
      time: 60,
      alpha: 5.0,
      mass: 56,
      volume: 19
    }).must_equal 34
  end

  it "must calculate hop mass required" do
    Hops.mass_required({
      extract: 1.05,
      time: 60,
      alpha: 5.0,
      ibus: 34,
      volume: 19
    }).must_equal 56
  end

  it "must calculate milliliters of HopShot required" do
    Hops.hopshot_required({
      ibus: 35,
      time: 60,
      volume: 19,
      extract: 1.045
    }).must_equal 3.5
  
    Hops.hopshot_required({
      ibus: 80,
      time: 60,
      volume: 38,
      extract: 1.085
    }).must_equal 17.6
  
    Hops.hopshot_required({
      ibus: 80,
      time: 60,
      volume: 38,
      extract: 1.1
    }).must_equal 19.2
  
    Hops.hopshot_required({
      ibus: 60,
      time: 90,
      volume: 19,
      extract: 1.15
    }).must_equal 7.2
  end

end
